package com.example.autoconfigure;

import com.example.autoconfigure.bean.Klass;
import com.example.autoconfigure.bean.School;
import com.example.autoconfigure.bean.Student;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author fangzhuangzhan
 * @date 2021/09/05 09:36
 */
@Configuration
@EnableConfigurationProperties(CustomerProperties.class)
public class CustomerAutoConfig {

    @Autowired
    private CustomerProperties customerProperties;

    @Bean
    public Student initStudent(){
        final Student student = new Student();
        student.setName(customerProperties.getStudentName());
        return student;
    }

    @Bean
    public Klass initKlass(){
        final Klass klass = new Klass();
        klass.setName(customerProperties.getKlassName());
        return klass;
    }

    @Bean
    public School initSchool(){
        final School school = new School();
        school.setName(customerProperties.getSchoolName());
        return school;
    }


}
